package com.itheima07;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

//集合的三种遍历方式
//1,  迭代器
//2,  增强for
//3,  Lambda表达式
public class SanZhongBianLi {
    public static void main(String[] args) {
        Collection<String> c = new ArrayList<>();
        c.add("JavaSE");
        c.add("JavaME");
        c.add("JavaEE");
        System.out.println("1,迭代器");
        Iterator<String> iter = c.iterator();
        while (iter.hasNext()) {
            String next = iter.next();
            System.out.println(next);
        }
        System.out.println("----------------");
        System.out.println("2,增强for");
        for (String s : c) {
            System.out.println(s);

        }
        System.out.println("---------------");
        System.out.println("3,lambda");
        c.forEach(s -> System.out.println(s));

    }


}
